import React, { Component } from 'react'
export class Test extends Component {
  constructor(props) {
    super(props)
    this.state = {
      message: 'Hellow React',
      age: 21,
    }
  }
  async changeText() {
    // this.setState本身的合并
    // this.setState({
    //   message: this.state.message + '6',
    // })
    // this.setState({
    //   message: this.state.message + '6',
    // })
    // this.setState({
    //   message: this.state.message + '7',
    // })
    this.setState((preState, props) => ({ message: preState.message + '6' }))
    this.setState((preState, props) => ({ message: preState.message + '6' }))
    this.setState((preState, props) => ({ message: preState.message + '6' }))
  }
  render() {
    return (
      <>
        <div>{this.state.message}</div>
        <button onClick={() => this.changeText()}>改变文本1</button>
        <div>{this.state.age}</div>
      </>
    )
  }
}
